"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var common_1 = require("@nestjs/common");
var functions_1 = require("../../../functions");
var DgramService = /** @class */ (function () {
    function DgramService() {
    }
    // 创建客户端
    DgramService.prototype.createSocket = function (type) {
        if (type === void 0) { type = 'udp4'; }
        return functions_1.createDgramSocket(type);
    };
    // 监听消息
    DgramService.prototype.on = function (server) {
        var close = rxjs_1.fromEvent(server, 'close');
        var error = rxjs_1.fromEvent(server, 'error');
        var listening = rxjs_1.fromEvent(server, 'listening');
        var message = rxjs_1.fromEvent(server, 'message');
        return rxjs_1.merge(close, error, listening, message);
    };
    DgramService = __decorate([
        common_1.Injectable()
    ], DgramService);
    return DgramService;
}());
exports.DgramService = DgramService;
